#include <benchmark/benchmark.h>
#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
#include "string.h"
#include "sys/uio.h"
#include "util.h"
using namespace std;

static void Bm_function_Writev(benchmark::State &state)
{
    char str1[] = "Hello,";
    char str2[] = "world!";
    struct iovec iov[2];
    ssize_t nwritten;
    iov[0].iov_base = str1;
    iov[0].iov_len = strlen(str1);
    iov[1].iov_base = str2;
    iov[1].iov_len = strlen(str2);

    for (auto _ : state)
    {
        nwritten = writev(STDOUT_FILENO, iov, 2);
        benchmark::DoNotOptimize(nwritten);
    }
    state.SetBytesProcessed(state.iterations());
}

MUSL_BENCHMARK(Bm_function_Writev);